import AdSelect from '@/components/AdSelect';

export const codes = {
  page: 'PARTSLIBRARY',
  select: 'PARTSLIBRARY_SELECT',
  add: 'PARTSLIBRARY_ADD',
  edit: 'PARTSLIBRARY_EDIT',
  remove: 'PARTSLIBRARY_DELETE',
  showDetail: 'PARTSLIBRARY_VIEW',
  export: 'BILLPAGE_SAVE',
};

export const allDispatchType = {
  list: 'PartsLib/selectPartsList',
  detail: 'PartsLib/partsDetails',
  remove: 'PartsLib/deleteParts',
  suppliersList: 'PartsLib/selectPartsSuppliersList',
  operate: 'PartsLib/partsOperate',
  queryPartsOfferDict: 'component/queryPartsOfferDict',
};
export const allUrl = {
  partsHierList: '/tms/tms-parts/selectTmsPartsHierList',
};

export function renderTableAdSelect({ key, data, value, props }) {
  let params = { onlyRead: true, value };
  if (key) {
    const { dictObject } = props;
    params = { data: dictObject[key], payload: { code: [key] }, ...params };
  } else {
    params = { data, ...params };
  }
  return <AdSelect {...params} />;
}
